#ifndef _USER_H_
#define _USER_H_

#include "headers.h"
#include "func.h"
#include "Comet.h"

using namespace std;

class Comet;

class User {
public:
	User() : opened(false), fdcnt(0) {}
	~User() { close(); }
	
	void setFd(SOCKET fd);
	void setComet(Comet* comet) {
		this->comet = comet;
	}
	void setUsername(const string& username) {
		this->username = username;
	}

	string getUsername() const {
		return username;
	}

	SOCKET getFd() { return fd; }
	bool isOpen() { return opened; }
	unsigned int getFdcnt() { return fdcnt; }

	void close();
	void addmsg(const string&);
private:
	void sendmsg(const string&);

	SOCKET fd;
	string username;
	bool opened;
	queue<string> msgs;
	Comet* comet;
	unsigned int fdcnt;
};

#endif
